var xmlhttp=false;

if (!xmlhttp && typeof XMLHttpRequest!='undefined')  {
     xmlhttp = new XMLHttpRequest();
     categoryTitleRequest = new XMLHttpRequest();
     updateCategory = new XMLHttpRequest();
}


function editCategory(id){
	
	
	if (document.getElementById('edit').style.visibility == 'visible'){
		document.getElementById('edit').style.visibility = 'hidden';
	}
	else{
		document.getElementById('edit').style.visibility = 'visible';
		categoryTitleRequest.open("GET", 'manageCategories.php?do=getCategoryName&id='+id, true);
	
		categoryTitleRequest.onreadystatechange=function(){
			if (categoryTitleRequest.readyState==4){
				document.getElementById('category-name').value = categoryTitleRequest.responseText;
				document.getElementById('edit-id').value = id;
			}
		}
		categoryTitleRequest.send(null);
		return false;	
	}
}

function update(){

	name = document.getElementById('category-name').value;
	id = document.getElementById('edit-id').value;

	updateCategory.open("GET", 'manageCategories.php?do=editCategory&id='+id+'name='+name, true);
	
	//updateCategory.onreadystatechange=function(){
	updateCategory.send(null)
		
}


